package mil.af.amc.adpetracker.web.actions.ItemModel;

import mil.af.amc.adpetracker.web.actions.AbstractAction;
import mil.af.amc.adpetracker.service.ItemModelService;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.DynaActionForm;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Action to edit a Item Model
 *
 * TODO: Method Level Security (?)
 *
 * @author TSgt Jason Ferguson
 */

public class EditItemModelAction extends AbstractAction {

    private ItemModelService itemModelService;

    public void setItemModelService(ItemModelService itemModelService) {
        this.itemModelService = itemModelService;
    }

    @Override
    public ActionForward execute(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {

        DynaActionForm form = (DynaActionForm) actionForm;
        itemModelService.editModel(form.getMap());


        return actionMapping.findForward("success");
    }
}
